#ifndef IOPCSCLITE_H
#define IOPCSCLITE_H

#ifdef WIN32
#undef UNICODE
static char *pcsc_stringify_error(LONG rv)
{
    static char out[20];
    sprintf_s(out, sizeof(out), "0x%08X", rv);
    return out;
}
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h> // strcmp

#ifdef __APPLE__
#include <PCSC/winscard.h>
#include <PCSC/wintypes.h>
#else
#include <winscard.h>
#endif

/// colors
#define RED     "\x1b[31m"
#define GREEN   "\x1b[32m"
#define YELLOW  "\x1b[33m"
#define BLUE    "\x1b[34m"
#define MAGENTA "\x1b[35m"
#define CYAN    "\x1b[36m"
#define RESET   "\x1b[0m"

void    hexPrintFromByteArray(size_t p, const unsigned char array[], size_t sz);
void    hexPrintFromCharArray(const char charArray[], size_t len);
void    charPrintOnly(const unsigned char array[], unsigned char fC);

long    sCardEstablishContext();
long    sCardListReaders(char* &mszReaders);
long    sCardConnect(const char* targetReader);
long    sCardTransmit(const unsigned char apdu[], size_t szApdu, unsigned char recvBuffer[], unsigned long &recvLength);
long    sCardDisconnect();
long    sCardFreeMemory();
long    sCardReleaseContext();

#endif // IOPCSCLITE_H
